﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class CheckInAwardsConfig extends Object
    {
        private var _map:Dictionary;
        private static var _instance:CheckInAwardsConfig;

        public function CheckInAwardsConfig()
        {
            this._map = new Dictionary();
            if (_instance)
            {
                throw new Error("CheckInAwardsConfig 单例");
            }
            this.init();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_check_in_awards.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TCheckInAwards = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TCheckInAwards();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._map[_loc_2.id] = _loc_2;
            }
            return;
        }// end function

        public function getInfoById(param1:int) : TCheckInAwards
        {
            return this._map[param1] as TCheckInAwards;
        }// end function

        public function getRewardsByTotalNum(param1:int, param2:Boolean) : String
        {
            var _loc_4:TCheckInAwards = null;
            var _loc_3:* = param2 ? (1) : (0);
            for each (_loc_4 in this._map)
            {
                
                if (_loc_4.requireDays == param1 && _loc_4.isvip == _loc_3)
                {
                    return _loc_4.itemlist1;
                }
            }
            return null;
        }// end function

        public function getRewardIdByDays(param1:int, param2:Boolean) : int
        {
            var _loc_4:TCheckInAwards = null;
            var _loc_3:* = param2 ? (1) : (0);
            for each (_loc_4 in this._map)
            {
                
                if (_loc_4.requireDays == param1 && _loc_4.isvip == _loc_3)
                {
                    return _loc_4.id;
                }
            }
            return 0;
        }// end function

        public function getAllRewardInfo() : Dictionary
        {
            return this._map;
        }// end function

        public static function get instance() : CheckInAwardsConfig
        {
            if (!_instance)
            {
                _instance = new CheckInAwardsConfig;
            }
            return _instance;
        }// end function

    }
}
